<div class="row">
    <div class="col-lg-12">
        <h3 class="page-header"><i class="fa fa-users"></i> 系统用户</h3>
        <ol class="breadcrumb">
            <li><i class="fa fa-cogs"></i><a href="index.html">系统设置</a></li>
            <li><i class="fa fa-users"></i>系统用户</li>
        </ol>
    </div>
</div>

<div class="row mbt_menubar">
    <div class="col-lg-12">
        <div class="pull-right">
            <a class="btn btn-primary" href="index.php?r=user/showedit&user_id=0"><i class="icon_plus_alt2"></i></a>
        </div>
    </div>
</div>

<div class="row">
    <div class="col-lg-12">
        <?php
        if(isset($message)){
            if($message['code']!=10000){
                ?>
                <div class="alert alert-block alert-danger fade in">
                    <button data-dismiss="alert" class="close close-sm" type="button">
                        <i class="icon-remove"></i>
                    </button>
                    <strong>警告：</strong> <?php echo $message['message']; ?>
                </div>
                <?php
            }else{
                ?>
                <div class="alert alert-success fade in">
                    <button data-dismiss="alert" class="close close-sm" type="button">
                        <i class="icon-remove"></i>
                    </button>
                    <strong>提示：</strong> <?php echo $message['message']; ?>
                </div>
                <?php
            }
        }
        ?>
    </div>
    <div class="col-lg-12">
        <section class="panel">
            <table class="table table-striped table-advance table-hover">
                <tbody>
                <tr>
                    <th>登入名</th>
                    <th>姓名</th>
                    <th style="width: 200px;">操作</th>
                </tr>
                <?php
                foreach ($users as $u){
                    ?>
                    <tr>
                        <td><?php echo $u['username']; ?></td>
                        <td><?php echo $u['realname']; ?></td>
                        <td>
                            <div class="btn-group">
                                <a class="btn btn-primary" href="index.php?r=user/showedit&user_id=<?php echo $u['user_id']; ?>"><i class="icon_pencil-edit"></i></a>
                                <a class="btn btn-danger" data-toggle="modal" href="#confirm" onclick="setRemovelocation('index.php?r=user/remove&user_id=<?php echo $u['user_id']; ?>')"><i class="icon_close_alt2"></i></a>
                                <a class="btn btn-info" href="index.php?r=user/resetpassword&user_id=<?php echo $u['user_id']; ?>"><i class="fa fa-key"></i></a>
                            </div>
                        </td>
                    </tr>
                    <?php
                }
                ?>
                </tbody>
            </table>
            <div class="modal fade" id="confirm" tabindex="-1" role="dialog" aria-labelledby="确认提示框" aria-hidden="true">
                <div class="modal-dialog">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                            <h4 class="modal-title">确认提示框</h4>
                        </div>
                        <div class="modal-body">
                            确定要删除该用户？
                        </div>
                        <div class="modal-footer">
                            <button data-dismiss="modal" class="btn btn-default" type="button">取消</button>
                            <button class="btn btn-warning" type="button" onclick="doremove()"> 确认</button>
                        </div>
                    </div>
                </div>
            </div>

        </section>
    </div>
</div>

<div class="row">
    <div class="col-lg-12">
        <div class="text-center">
            <?php
            $this->widget('CLinkPager', array(
                    'header' => '',
                    'firstPageLabel' => Yii::t("分页","首页"),
                    'lastPageLabel' =>Yii::t("分页", "末页"),
                    'prevPageLabel' =>Yii::t("分页", "上一页"),
                    'nextPageLabel' => Yii::t("分页", "下一页"),
                    'pages' => $pages,
                    'htmlOptions'=>array('class'=>'pagination')
                )
            );
            ?>
        </div>
    </div>
</div>

<script>
    var remove = null;
    $(function () {
        $("#menu_sysconfig").addClass("active");
        $("#menu_sysconfig .menu-arrow").removeClass("arrow_carrot-right").addClass("arrow_carrot-down");
        $("#item_sysconfig_user_module").parent("li").addClass("active");
    });
    function setRemovelocation(removelocation) {
        remove = removelocation;
    }
    function doremove() {
        window.location.href = remove;
    }
</script>